package com.fa4j.common.base.util;

import java.math.BigDecimal;

public class BigDecimalUtil {

    public static BigDecimal min(BigDecimal first, BigDecimal second) {
        if (first.compareTo(second) < 0) {
            return first;
        } else {
            return second;
        }
    }

    public static BigDecimal max(BigDecimal first, BigDecimal second) {
        if (first.compareTo(second) > 0) {
            return first;
        } else {
            return second;
        }
    }

    public static BigDecimal multiply(BigDecimal amount, Integer quantity) {
        if (amount == null || quantity == null) {
            return null;
        }
        return amount.multiply(new BigDecimal("" + quantity));
    }

    public static boolean isEquals(BigDecimal first, BigDecimal second) {
        if (first == null || second == null) {
            return true;
        }
        if (first != null && second != null) {
            return first.compareTo(second) == 0;
        }
        return false;
    }

    public static boolean isNotEquals(BigDecimal first, BigDecimal second) {
        return !isEquals(first, second);
    }

    public static boolean isZero(BigDecimal first) {
        return isEquals(first, BigDecimal.ZERO);
    }
}
